<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>基本数据类型</title>
</head>

<body>
    <!--
        * 基本类型
            * String : 任意字符串
            * Number: 任意的数字
            * boolean: true/false
            * undefined: undefined
            * null: null
        * 
        undefined: 代表定义未赋值
        * null: 定义赋值为null
        
    -->


    <script type="text/javascript">

        var a
        console.log(a, typeof a, typeof a === 'undefined', a === undefined);
        console.log(undefined === 'undefined');

        a = 3
        console.log(typeof a === 'number');

        a = "abadd"
        console.log(typeof a === 'string');
        a = true
        console.log(typeof a === 'boolean');

        a = null
        console.log(typeof a, a === null);

        var b1 = {
            b2: [1, 'abc', console.log],
            b3: function () {
                console.log('b3');
                var i = 10;
                return function () {
                    for (; i < 100; i += 10) {
                        console.log(i);
                    }
                }
            }
        }

        console.log(b1 instanceof Object, b1 instanceof Array); //true false
        console.log(b1.b2 instanceof Array, b1.b2 instanceof Object); //true true
        console.log(b1.b3 instanceof Function, b1.b3 instanceof Object);//true true

        console.log(typeof b1.b3 === 'function'); //true
        console.log(typeof b1.b2[2] === 'function'); //true
        b1.b2[2](4) //4

        console.log(b1.b3()());

        var obj = {
            name: 'Tom',
            age: 12
        }
        function test() {
            var a = 3
        }
        var arr = [3, 'abc']
        arr[1]

    </script>
</body>

</html>